home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume13 / rpc3.9 / part09 < prev    next >
Encoding:
Internet Message Format  |  1988-02-27  |  25.7 KB

  1. Subject:  v13i086:  Sun RPC, release 3.9, Part09/15
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Stephen X. Nahm <sxn@Sun.COM>
  7. Posting-number: Volume 13, Issue 86
  8. Archive-name: rpc3.9/part09
  9.  
  10. #! /bin/sh
  11. # This is a shell archive. To extract, remove the header and type "sh filename"
  12. #
  13. cd rpcsvc
  14. cat > rstat.x <<'Funky_Stuff'
  15. /* @(#)rstat.x    1.2 87/11/12 3.9 RPCSRC */
  16. /* @(#)rstat.x 1.2 87/09/18 Copyr 1987 Sun Micro */
  17.  
  18. /*
  19.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  20.  * unrestricted use provided that this legend is included on all tape
  21.  * media and as a part of the software program in whole or part.  Users
  22.  * may copy or modify Sun RPC without charge, but are not authorized
  23.  * to license or distribute it to anyone else except as part of a product or
  24.  * program developed by the user.
  25.  * 
  26.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  27.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  28.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  29.  * 
  30.  * Sun RPC is provided with no support and without any obligation on the
  31.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  32.  * modification or enhancement.
  33.  * 
  34.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  35.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  36.  * OR ANY PART THEREOF.
  37.  * 
  38.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  39.  * or profits or other special, indirect and consequential damages, even if
  40.  * Sun has been advised of the possibility of such damages.
  41.  * 
  42.  * Sun Microsystems, Inc.
  43.  * 2550 Garcia Avenue
  44.  * Mountain View, California  94043
  45.  */
  46.  
  47. /*
  48.  * Gather statistics on remote machines
  49.  */
  50.  
  51. const CPUSTATES = 4;
  52. const DK_NDRIVE = 4;
  53.  
  54. /*
  55.  * GMT since 0:00, January 1, 1970
  56.  */
  57. struct rstat_timeval {
  58.     unsigned int tv_sec;    /* seconds */
  59.     unsigned int tv_usec;    /* and microseconds */
  60. };
  61.  
  62. struct statstime {                /* RSTATVERS_TIME */
  63.     int cp_time[CPUSTATES];
  64.     int dk_xfer[DK_NDRIVE];
  65.     unsigned int v_pgpgin;    /* these are cumulative sum */
  66.     unsigned int v_pgpgout;
  67.     unsigned int v_pswpin;
  68.     unsigned int v_pswpout;
  69.     unsigned int v_intr;
  70.     int if_ipackets;
  71.     int if_ierrors;
  72.     int if_oerrors;
  73.     int if_collisions;
  74.     unsigned int v_swtch;
  75.     int avenrun[3];
  76.     rstat_timeval boottime;
  77.     rstat_timeval curtime;
  78.     int if_opackets;
  79. };
  80.  
  81. struct statsswtch {            /* RSTATVERS_SWTCH */
  82.     int cp_time[CPUSTATES];
  83.     int dk_xfer[DK_NDRIVE];
  84.     unsigned int v_pgpgin;    /* these are cumulative sum */
  85.     unsigned int v_pgpgout;
  86.     unsigned int v_pswpin;
  87.     unsigned int v_pswpout;
  88.     unsigned int v_intr;
  89.     int if_ipackets;
  90.     int if_ierrors;
  91.     int if_oerrors;
  92.     int if_collisions;
  93.     unsigned int v_swtch;
  94.     unsigned int avenrun[3];
  95.     rstat_timeval boottime;
  96.     int if_opackets;
  97. };
  98.  
  99. struct stats {                /* RSTATVERS_ORIG */
  100.     int cp_time[CPUSTATES];
  101.     int dk_xfer[DK_NDRIVE];
  102.     unsigned int v_pgpgin;    /* these are cumulative sum */
  103.     unsigned int v_pgpgout;
  104.     unsigned int v_pswpin;
  105.     unsigned int v_pswpout;
  106.     unsigned int v_intr;
  107.     int if_ipackets;
  108.     int if_ierrors;
  109.     int if_oerrors;
  110.     int if_collisions;
  111.     int if_opackets;
  112. };
  113.  
  114.  
  115. program RSTATPROG {
  116.     /*
  117.      * Newest version includes current time and context switching info
  118.      */
  119.     version RSTATVERS_TIME {
  120.         statstime
  121.         RSTATPROC_STATS(void) = 1;
  122.  
  123.         unsigned int
  124.         RSTATPROC_HAVEDISK(void) = 2;
  125.     } = 3;
  126.     /*
  127.      * Does not have current time
  128.      */
  129.     version RSTATVERS_SWTCH {
  130.         statsswtch
  131.         RSTATPROC_STATS(void) = 1;
  132.  
  133.         unsigned int
  134.         RSTATPROC_HAVEDISK(void) = 2;
  135.     } = 2;
  136.     /*
  137.      * Old version has no info about current time or context switching
  138.      */
  139.     version RSTATVERS_ORIG {
  140.         stats
  141.         RSTATPROC_STATS(void) = 1;
  142.  
  143.         unsigned int
  144.         RSTATPROC_HAVEDISK(void) = 2;
  145.     } = 1;
  146. } = 100001;
  147. Funky_Stuff
  148. len=`wc -c < rstat.x`
  149. if [ $len !=     3375 ] ; then
  150.   echo error: rstat.x was $len bytes long, should have been     3375
  151. fi
  152. echo x - rstat_proc.c
  153. cat > rstat_proc.c <<'Funky_Stuff'
  154. /* @(#)rstat_proc.c    1.2 87/11/24 3.9 RPCSRC */
  155. #ifndef lint
  156. static  char sccsid[] = "@(#)rpc.rstatd.c 1.1 86/09/25 Copyr 1984 Sun Micro";
  157. #endif
  158.  
  159. /*
  160.  * Copyright (c) 1984 by Sun Microsystems, Inc.
  161.  */
  162.  
  163. /*
  164.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  165.  * unrestricted use provided that this legend is included on all tape
  166.  * media and as a part of the software program in whole or part.  Users
  167.  * may copy or modify Sun RPC without charge, but are not authorized
  168.  * to license or distribute it to anyone else except as part of a product or
  169.  * program developed by the user.
  170.  *
  171.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  172.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  173.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  174.  *
  175.  * Sun RPC is provided with no support and without any obligation on the
  176.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  177.  * modification or enhancement.
  178.  *
  179.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  180.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  181.  * OR ANY PART THEREOF.
  182.  *
  183.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  184.  * or profits or other special, indirect and consequential damages, even if
  185.  * Sun has been advised of the possibility of such damages.
  186.  *
  187.  * Sun Microsystems, Inc.
  188.  * 2550 Garcia Avenue
  189.  * Mountain View, California  94043
  190.  */
  191.  
  192. /*
  193.  * rstat service:  built with rstat.x and derived from rpc.rstatd.c
  194.  */
  195.  
  196. #include <signal.h>
  197. #include <stdio.h>
  198. #include <rpc/rpc.h>
  199. #include <sys/socket.h>
  200. #include <nlist.h>
  201. #include <sys/dk.h>
  202. #include <sys/errno.h>
  203. #include <sys/vmmeter.h>
  204. #include <net/if.h>
  205. #include <sys/time.h>
  206. #include "rstat.h"
  207.  
  208. struct nlist nl[] = {
  209. #define    X_CPTIME    0
  210.     { "_cp_time" },
  211. #define    X_SUM        1
  212.     { "_sum" },
  213. #define    X_IFNET        2
  214.     { "_ifnet" },
  215. #define    X_DKXFER    3
  216.     { "_dk_xfer" },
  217. #define    X_BOOTTIME    4
  218.     { "_boottime" },
  219. #define    X_AVENRUN    5
  220.     { "_avenrun" },
  221. #define X_HZ        6
  222.     { "_hz" },
  223.     "",
  224. };
  225. int kmem;
  226. int firstifnet, numintfs;    /* chain of ethernet interfaces */
  227. int stats_service();
  228.  
  229. /*
  230.  *  Define EXIT_WHEN_IDLE if you are able to have this program invoked
  231.  *  automatically on demand (as from inetd).  When defined, the service
  232.  *  will terminated after being idle for 20 seconds.
  233.  */
  234. int sincelastreq = 0;        /* number of alarms since last request */
  235. #ifdef EXIT_WHEN_IDLE
  236. #define CLOSEDOWN 20        /* how long to wait before exiting */
  237. #endif /* def EXIT_WHEN_IDLE */
  238.  
  239. union {
  240.     struct stats s1;
  241.     struct statsswtch s2;
  242.     struct statstime s3;
  243. } stats_all;
  244.  
  245. int updatestat();
  246. static stat_is_init = 0;
  247. extern int errno;
  248.  
  249. #ifndef FSCALE
  250. #define FSCALE (1 << 8)
  251. #endif
  252.  
  253. stat_init()
  254. {
  255.     stat_is_init = 1;
  256.     setup();
  257.     updatestat();
  258.     alarm(1);
  259.     signal(SIGALRM, updatestat);
  260.     sleep(1);               /* allow for one wake-up */
  261. }
  262.  
  263. statstime *
  264. rstatproc_stats_3()
  265. {
  266.     if (! stat_is_init)
  267.         stat_init();
  268.     sincelastreq = 0;
  269.     return(&stats_all.s3);
  270. }
  271.  
  272. statsswtch *
  273. rstatproc_stats_2()
  274. {
  275.     if (! stat_is_init)
  276.         stat_init();
  277.     sincelastreq = 0;
  278.     return(&stats_all.s2);
  279. }
  280.  
  281. stats *
  282. rstatproc_stats_1()
  283. {
  284.     if (! stat_is_init)
  285.         stat_init();
  286.     sincelastreq = 0;
  287.     return(&stats_all.s1);
  288. }
  289.  
  290. u_int *
  291. rstatproc_havedisk_3()
  292. {
  293.     static u_int have;
  294.  
  295.     if (! stat_is_init)
  296.         stat_init();
  297.     sincelastreq = 0;
  298.     have = havedisk();
  299.     return(&have);
  300. }
  301.  
  302. u_int *
  303. rstatproc_havedisk_2()
  304. {
  305.     return(rstatproc_havedisk_3());
  306. }
  307.  
  308. u_int *
  309. rstatproc_havedisk_1()
  310. {
  311.     return(rstatproc_havedisk_3());
  312. }
  313.  
  314. updatestat()
  315. {
  316.     int off, i, hz;
  317.     struct vmmeter sum;
  318.     struct ifnet ifnet;
  319.     double avrun[3];
  320.     struct timeval tm, btm;
  321.  
  322. #ifdef DEBUG
  323.     fprintf(stderr, "entering updatestat\n");
  324. #endif
  325. #ifdef EXIT_WHEN_IDLE
  326.     if (sincelastreq >= CLOSEDOWN) {
  327. #ifdef DEBUG
  328.     fprintf(stderr, "about to closedown\n");
  329. #endif
  330.         exit(0);
  331.     }
  332.     sincelastreq++;
  333. #endif /* def EXIT_WHEN_IDLE */
  334.     if (lseek(kmem, (long)nl[X_HZ].n_value, 0) == -1) {
  335.         fprintf(stderr, "rstat: can't seek in kmem\n");
  336.         exit(1);
  337.     }
  338.     if (read(kmem, (char *)&hz, sizeof hz) != sizeof hz) {
  339.         fprintf(stderr, "rstat: can't read hz from kmem\n");
  340.         exit(1);
  341.     }
  342.     if (lseek(kmem, (long)nl[X_CPTIME].n_value, 0) == -1) {
  343.         fprintf(stderr, "rstat: can't seek in kmem\n");
  344.         exit(1);
  345.     }
  346.      if (read(kmem, (char *)stats_all.s1.cp_time, sizeof (stats_all.s1.cp_time))
  347.         != sizeof (stats_all.s1.cp_time)) {
  348.         fprintf(stderr, "rstat: can't read cp_time from kmem\n");
  349.         exit(1);
  350.     }
  351.     if (lseek(kmem, (long)nl[X_AVENRUN].n_value, 0) ==-1) {
  352.         fprintf(stderr, "rstat: can't seek in kmem\n");
  353.         exit(1);
  354.     }
  355. #ifdef vax
  356.      if (read(kmem, (char *)avrun, sizeof (avrun)) != sizeof (avrun)) {
  357.         fprintf(stderr, "rstat: can't read avenrun from kmem\n");
  358.         exit(1);
  359.     }
  360.     stats_all.s2.avenrun[0] = avrun[0] * FSCALE;
  361.     stats_all.s2.avenrun[1] = avrun[1] * FSCALE;
  362.     stats_all.s2.avenrun[2] = avrun[2] * FSCALE;
  363. #endif
  364.     if (lseek(kmem, (long)nl[X_BOOTTIME].n_value, 0) == -1) {
  365.         fprintf(stderr, "rstat: can't seek in kmem\n");
  366.         exit(1);
  367.     }
  368.      if (read(kmem, (char *)&btm, sizeof (stats_all.s2.boottime))
  369.         != sizeof (stats_all.s2.boottime)) {
  370.         fprintf(stderr, "rstat: can't read boottime from kmem\n");
  371.         exit(1);
  372.     }
  373.     stats_all.s2.boottime.tv_sec = btm.tv_sec;
  374.     stats_all.s2.boottime.tv_usec = btm.tv_usec;
  375.  
  376.  
  377. #ifdef DEBUG
  378.     fprintf(stderr, "%d %d %d %d\n", stats_all.s1.cp_time[0],
  379.         stats_all.s1.cp_time[1], stats_all.s1.cp_time[2], stats_all.s1.cp_time[3]);
  380. #endif
  381.  
  382.     if (lseek(kmem, (long)nl[X_SUM].n_value, 0) ==-1) {
  383.         fprintf(stderr, "rstat: can't seek in kmem\n");
  384.         exit(1);
  385.     }
  386.      if (read(kmem, (char *)&sum, sizeof sum) != sizeof sum) {
  387.         fprintf(stderr, "rstat: can't read sum from kmem\n");
  388.         exit(1);
  389.     }
  390.     stats_all.s1.v_pgpgin = sum.v_pgpgin;
  391.     stats_all.s1.v_pgpgout = sum.v_pgpgout;
  392.     stats_all.s1.v_pswpin = sum.v_pswpin;
  393.     stats_all.s1.v_pswpout = sum.v_pswpout;
  394.     stats_all.s1.v_intr = sum.v_intr;
  395.     gettimeofday(&tm, (struct timezone *) 0);
  396.     stats_all.s1.v_intr -= hz*(tm.tv_sec - btm.tv_sec) +
  397.         hz*(tm.tv_usec - btm.tv_usec)/1000000;
  398.     stats_all.s2.v_swtch = sum.v_swtch;
  399.  
  400.     if (lseek(kmem, (long)nl[X_DKXFER].n_value, 0) == -1) {
  401.         fprintf(stderr, "rstat: can't seek in kmem\n");
  402.         exit(1);
  403.     }
  404.      if (read(kmem, (char *)stats_all.s1.dk_xfer, sizeof (stats_all.s1.dk_xfer))
  405.         != sizeof (stats_all.s1.dk_xfer)) {
  406.         fprintf(stderr, "rstat: can't read dk_xfer from kmem\n");
  407.         exit(1);
  408.     }
  409.  
  410.     stats_all.s1.if_ipackets = 0;
  411.     stats_all.s1.if_opackets = 0;
  412.     stats_all.s1.if_ierrors = 0;
  413.     stats_all.s1.if_oerrors = 0;
  414.     stats_all.s1.if_collisions = 0;
  415.     for (off = firstifnet, i = 0; off && i < numintfs; i++) {
  416.         if (lseek(kmem, (long)off, 0) == -1) {
  417.             fprintf(stderr, "rstat: can't seek in kmem\n");
  418.             exit(1);
  419.         }
  420.         if (read(kmem, (char *)&ifnet, sizeof ifnet) != sizeof ifnet) {
  421.             fprintf(stderr, "rstat: can't read ifnet from kmem\n");
  422.             exit(1);
  423.         }
  424.         stats_all.s1.if_ipackets += ifnet.if_ipackets;
  425.         stats_all.s1.if_opackets += ifnet.if_opackets;
  426.         stats_all.s1.if_ierrors += ifnet.if_ierrors;
  427.         stats_all.s1.if_oerrors += ifnet.if_oerrors;
  428.         stats_all.s1.if_collisions += ifnet.if_collisions;
  429.         off = (int) ifnet.if_next;
  430.     }
  431.     gettimeofday((struct timeval *)&stats_all.s3.curtime,
  432.         (struct timezone *) 0);
  433.     alarm(1);
  434. }
  435.  
  436. static 
  437. setup()
  438. {
  439.     struct ifnet ifnet;
  440.     int off;
  441.  
  442.     nlist("/vmunix", nl);
  443.     if (nl[0].n_value == 0) {
  444.         fprintf(stderr, "rstat: Variables missing from namelist\n");
  445.         exit (1);
  446.     }
  447.     if ((kmem = open("/dev/kmem", 0)) < 0) {
  448.         fprintf(stderr, "rstat: can't open kmem\n");
  449.         exit(1);
  450.     }
  451.  
  452.     off = nl[X_IFNET].n_value;
  453.     if (lseek(kmem, (long)off, 0) == -1) {
  454.         fprintf(stderr, "rstat: can't seek in kmem\n");
  455.         exit(1);
  456.     }
  457.     if (read(kmem, (char *)&firstifnet, sizeof(int)) != sizeof (int)) {
  458.         fprintf(stderr, "rstat: can't read firstifnet from kmem\n");
  459.         exit(1);
  460.     }
  461.     numintfs = 0;
  462.     for (off = firstifnet; off;) {
  463.         if (lseek(kmem, (long)off, 0) == -1) {
  464.             fprintf(stderr, "rstat: can't seek in kmem\n");
  465.             exit(1);
  466.         }
  467.         if (read(kmem, (char *)&ifnet, sizeof ifnet) != sizeof ifnet) {
  468.             fprintf(stderr, "rstat: can't read ifnet from kmem\n");
  469.             exit(1);
  470.         }
  471.         numintfs++;
  472.         off = (int) ifnet.if_next;
  473.     }
  474. }
  475.  
  476. /*
  477.  * returns true if have a disk
  478.  */
  479. static
  480. havedisk()
  481. {
  482.     int i, cnt;
  483.     long  xfer[DK_NDRIVE];
  484.  
  485.     nlist("/vmunix", nl);
  486.     if (nl[X_DKXFER].n_value == 0) {
  487.         fprintf(stderr, "rstat: Variables missing from namelist\n");
  488.         exit (1);
  489.     }
  490.     if ((kmem = open("/dev/kmem", 0)) < 0) {
  491.         fprintf(stderr, "rstat: can't open kmem\n");
  492.         exit(1);
  493.     }
  494.     if (lseek(kmem, (long)nl[X_DKXFER].n_value, 0) == -1) {
  495.         fprintf(stderr, "rstat: can't seek in kmem\n");
  496.         exit(1);
  497.     }
  498.     if (read(kmem, (char *)xfer, sizeof xfer)!= sizeof xfer) {
  499.         fprintf(stderr, "rstat: can't read kmem\n");
  500.         exit(1);
  501.     }
  502.     cnt = 0;
  503.     for (i=0; i < DK_NDRIVE; i++)
  504.         cnt += xfer[i];
  505.     return (cnt != 0);
  506. }
  507. Funky_Stuff
  508. len=`wc -c < rstat_proc.c`
  509. if [ $len !=     8813 ] ; then
  510.   echo error: rstat_proc.c was $len bytes long, should have been     8813
  511. fi
  512. echo x - sm_inter.x
  513. cat > sm_inter.x <<'Funky_Stuff'
  514. /* @(#)sm_inter.x    1.2 87/11/12 3.9 RPCSRC */
  515. /* @(#)sm_inter.x 1.7 87/06/24 Copyr 1987 Sun Micro */
  516.  
  517. /*
  518.  * Status monitor protocol specification
  519.  * Copyright (C) 1986 Sun Microsystems, Inc.
  520.  *
  521.  */
  522.  
  523.  
  524. program SM_PROG { 
  525.     version SM_VERS  {
  526.         /* res_stat = stat_succ if status monitor agrees to monitor */
  527.         /* res_stat = stat_fail if status monitor cannot monitor */
  528.         /* if res_stat == stat_succ, state = state number of site sm_name */
  529.         struct sm_stat_res             SM_STAT(struct sm_name) = 1;
  530.  
  531.         /* res_stat = stat_succ if status monitor agrees to monitor */
  532.         /* res_stat = stat_fail if status monitor cannot monitor */
  533.         /* stat consists of state number of local site */
  534.         struct sm_stat_res             SM_MON(struct mon) = 2;
  535.  
  536.         /* stat consists of state number of local site */
  537.         struct sm_stat                 SM_UNMON(struct mon_id) = 3;
  538.  
  539.         /* stat consists of state number of local site */
  540.         struct sm_stat                 SM_UNMON_ALL(struct my_id) = 4;
  541.  
  542.         void                     SM_SIMU_CRASH(void) = 5;
  543.  
  544.     } = 1;
  545. } = 100024;
  546.  
  547. const    SM_MAXSTRLEN = 1024;
  548.  
  549. struct sm_name {
  550.     string mon_name<SM_MAXSTRLEN>;
  551. };
  552.  
  553. struct my_id {
  554.     string     my_name<SM_MAXSTRLEN>;        /* name of the site iniates the monitoring request*/
  555.     int    my_prog;            /* rpc program # of the requesting process */
  556.     int    my_vers;            /* rpc version # of the requesting process */
  557.     int    my_proc;            /* rpc procedure # of the requesting process */
  558. };
  559.  
  560. struct mon_id {
  561.     string    mon_name<SM_MAXSTRLEN>;        /* name of the site to be monitored */
  562.     struct my_id my_id;
  563. };
  564.  
  565.  
  566. struct mon{
  567.     struct mon_id mon_id;
  568.     opaque priv[16];         /* private information to store at monitor for requesting process */
  569. };
  570.  
  571.  
  572. /*
  573.  * state # of status monitor monitonically increases each time
  574.  * status of the site changes:
  575.  * an even number (>= 0) indicates the site is down and
  576.  * an odd number (> 0) indicates the site is up;
  577.  */
  578. struct sm_stat {
  579.     int state;        /* state # of status monitor */
  580. };
  581.  
  582. enum res {
  583.     stat_succ = 0,        /* status monitor agrees to monitor */
  584.     stat_fail = 1        /* status monitor cannot monitor */
  585. };
  586.  
  587. struct sm_stat_res {
  588.     res res_stat;
  589.     int state;
  590. };
  591.  
  592. /* 
  593.  * structure of the status message sent back by the status monitor
  594.  * when monitor site status changes
  595.  */
  596. struct status {
  597.     string mon_name<SM_MAXSTRLEN>;
  598.     int state;
  599.     opaque priv[16];        /* stored private information */
  600. };
  601. Funky_Stuff
  602. len=`wc -c < sm_inter.x`
  603. if [ $len !=     2276 ] ; then
  604.   echo error: sm_inter.x was $len bytes long, should have been     2276
  605. fi
  606. echo x - spray.x
  607. cat > spray.x <<'Funky_Stuff'
  608. /* @(#)spray.x    1.2 87/11/12 3.9 RPCSRC */
  609. /* @(#)spray.x 1.2 87/09/18 Copyr 1987 Sun Micro */
  610.  
  611. /*
  612.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  613.  * unrestricted use provided that this legend is included on all tape
  614.  * media and as a part of the software program in whole or part.  Users
  615.  * may copy or modify Sun RPC without charge, but are not authorized
  616.  * to license or distribute it to anyone else except as part of a product or
  617.  * program developed by the user.
  618.  * 
  619.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  620.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  621.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  622.  * 
  623.  * Sun RPC is provided with no support and without any obligation on the
  624.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  625.  * modification or enhancement.
  626.  * 
  627.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  628.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  629.  * OR ANY PART THEREOF.
  630.  * 
  631.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  632.  * or profits or other special, indirect and consequential damages, even if
  633.  * Sun has been advised of the possibility of such damages.
  634.  * 
  635.  * Sun Microsystems, Inc.
  636.  * 2550 Garcia Avenue
  637.  * Mountain View, California  94043
  638.  */
  639.  
  640. /*
  641.  * Spray a server with packets
  642.  * Useful for testing flakiness of network interfaces
  643.  */
  644.  
  645. const SPRAYMAX = 8845;    /* max amount can spray */
  646.  
  647. /*
  648.  * GMT since 0:00, 1 January 1970
  649.  */
  650. struct spraytimeval {
  651.     unsigned int sec;
  652.     unsigned int usec;
  653. };
  654.  
  655. /*
  656.  * spray statistics
  657.  */
  658. struct spraycumul {
  659.     unsigned int counter;
  660.     spraytimeval clock;
  661. };
  662.  
  663. /*
  664.  * spray data
  665.  */
  666. typedef opaque sprayarr<SPRAYMAX>;
  667.  
  668. program SPRAYPROG {
  669.     version SPRAYVERS {
  670.         /*
  671.          * Just throw away the data and increment the counter
  672.          * This call never returns, so the client should always 
  673.          * time it out.
  674.          */
  675.         void
  676.         SPRAYPROC_SPRAY(sprayarr) = 1;
  677.  
  678.         /*
  679.          * Get the value of the counter and elapsed time  since
  680.          * last CLEAR.
  681.          */
  682.         spraycumul    
  683.         SPRAYPROC_GET(void) = 2;
  684.  
  685.         /*
  686.          * Clear the counter and reset the elapsed time
  687.          */
  688.         void
  689.         SPRAYPROC_CLEAR(void) = 3;
  690.     } = 1;
  691. } = 100012;
  692. Funky_Stuff
  693. len=`wc -c < spray.x`
  694. if [ $len !=     2238 ] ; then
  695.   echo error: spray.x was $len bytes long, should have been     2238
  696. fi
  697. echo x - yp.x
  698. cat > yp.x <<'Funky_Stuff'
  699. /* @(#)yp.x    1.2 87/11/12 3.9 RPCSRC */
  700.  
  701. /*
  702.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  703.  * unrestricted use provided that this legend is included on all tape
  704.  * media and as a part of the software program in whole or part.  Users
  705.  * may copy or modify Sun RPC without charge, but are not authorized
  706.  * to license or distribute it to anyone else except as part of a product or
  707.  * program developed by the user.
  708.  * 
  709.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  710.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  711.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  712.  * 
  713.  * Sun RPC is provided with no support and without any obligation on the
  714.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  715.  * modification or enhancement.
  716.  * 
  717.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  718.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  719.  * OR ANY PART THEREOF.
  720.  * 
  721.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  722.  * or profits or other special, indirect and consequential damages, even if
  723.  * Sun has been advised of the possibility of such damages.
  724.  * 
  725.  * Sun Microsystems, Inc.
  726.  * 2550 Garcia Avenue
  727.  * Mountain View, California  94043
  728.  */
  729.  
  730. /*
  731.  * Protocol description file for the Yellow Pages Service
  732.  */
  733.  
  734. const YPMAXRECORD = 1024;
  735. const YPMAXDOMAIN = 64;
  736. const YPMAXMAP = 64;
  737. const YPMAXPEER = 64;
  738.  
  739.  
  740. enum ypstat {
  741.     YP_TRUE        =  1,
  742.     YP_NOMORE    =  2,
  743.     YP_FALSE    =  0,
  744.     YP_NOMAP    = -1,
  745.     YP_NODOM    = -2,
  746.     YP_NOKEY    = -3,
  747.     YP_BADOP    = -4,
  748.     YP_BADDB    = -5,
  749.     YP_YPERR    = -6,
  750.     YP_BADARGS    = -7,
  751.     YP_VERS        = -8
  752. };
  753.  
  754.  
  755. enum ypxfrstat {
  756.     YPXFR_SUCC    =  1,
  757.     YPXFR_AGE    =  2,
  758.     YPXFR_NOMAP    = -1,
  759.     YPXFR_NODOM    = -2,
  760.     YPXFR_RSRC    = -3,
  761.     YPXFR_RPC    = -4,
  762.     YPXFR_MADDR    = -5,
  763.     YPXFR_YPERR    = -6,
  764.     YPXFR_BADARGS    = -7,
  765.     YPXFR_DBM    = -8,
  766.     YPXFR_FILE    = -9,
  767.     YPXFR_SKEW    = -10,
  768.     YPXFR_CLEAR    = -11,
  769.     YPXFR_FORCE    = -12,
  770.     YPXFR_XFRERR    = -13,
  771.     YPXFR_REFUSED    = -14
  772. };
  773.  
  774.  
  775. typedef string domainname<YPMAXDOMAIN>;
  776. typedef string mapname<YPMAXMAP>;
  777. typedef string peername<YPMAXPEER>;
  778. typedef opaque keydat<YPMAXRECORD>;
  779. typedef opaque valdat<YPMAXRECORD>;
  780.  
  781.  
  782. struct ypmap_parms {
  783.     domainname domain;    
  784.     mapname map;
  785.     unsigned int ordernum;
  786.     peername peer;
  787. };
  788.  
  789. struct ypreq_key {
  790.     domainname domain;
  791.     mapname map;
  792.     keydat key;
  793. };
  794.  
  795. struct ypreq_nokey {
  796.     domainname domain;    
  797.     mapname map;
  798. };
  799.     
  800. struct ypreq_xfr {
  801.     ypmap_parms map_parms;
  802.     unsigned int transid;
  803.     unsigned int prog;
  804.     unsigned int port;
  805. };
  806.  
  807.  
  808. struct ypresp_val {
  809.     ypstat stat;
  810.     valdat val;
  811. };
  812.  
  813. struct ypresp_key_val {
  814.     ypstat stat;
  815.     keydat key;
  816.     valdat val;
  817. };
  818.  
  819.  
  820. struct ypresp_master {
  821.     ypstat stat;    
  822.     peername peer;
  823. };
  824.  
  825. struct ypresp_order {
  826.     ypstat stat;
  827.     unsigned int ordernum;
  828. };
  829.  
  830. union ypresp_all switch (bool more) {
  831. case TRUE:
  832.     ypresp_key_val val;
  833. case FALSE:
  834.     void;
  835. };
  836.  
  837. struct ypresp_xfr {
  838.     unsigned int transid;
  839.     ypxfrstat xfrstat;
  840. };
  841.  
  842. struct ypmaplist {
  843.     mapname map;
  844.     ypmaplist *next;
  845. };
  846.  
  847. struct ypresp_maplist {
  848.     ypstat stat;
  849.     ypmaplist *maps;
  850. };
  851.  
  852. enum yppush_status {
  853.     YPPUSH_SUCC    =  1,    /* Success */
  854.     YPPUSH_AGE     =  2,    /* Master's version not newer */
  855.     YPPUSH_NOMAP    = -1,    /* Can't find server for map */
  856.     YPPUSH_NODOM    = -2,    /* Domain not supported */
  857.     YPPUSH_RSRC    = -3,    /* Local resource alloc failure */
  858.     YPPUSH_RPC    = -4,    /* RPC failure talking to server */
  859.     YPPUSH_MADDR     = -5,    /* Can't get master address */
  860.     YPPUSH_YPERR    = -6,    /* YP server/map db error */
  861.     YPPUSH_BADARGS    = -7,    /* Request arguments bad */
  862.     YPPUSH_DBM    = -8,    /* Local dbm operation failed */
  863.     YPPUSH_FILE    = -9,    /* Local file I/O operation failed */
  864.     YPPUSH_SKEW    = -10,    /* Map version skew during transfer */
  865.     YPPUSH_CLEAR    = -11,    /* Can't send "Clear" req to local ypserv */
  866.     YPPUSH_FORCE    = -12,    /* No local order number in map  use -f flag. */
  867.     YPPUSH_XFRERR     = -13,    /* ypxfr error */
  868.     YPPUSH_REFUSED    = -14     /* Transfer request refused by ypserv */
  869. };
  870.  
  871. struct yppushresp_xfr {
  872.     unsigned transid;
  873.     yppush_status status;
  874. };
  875.  
  876. /*
  877.  * Response structure and overall result status codes.  Success and failure
  878.  * represent two separate response message types.
  879.  */
  880.  
  881. enum ypbind_resptype {
  882.     YPBIND_SUCC_VAL = 1, 
  883.     YPBIND_FAIL_VAL = 2
  884. };
  885.  
  886. struct ypbind_binding {
  887.     opaque ypbind_binding_addr[4]; /* In network order */
  888.     opaque ypbind_binding_port[2]; /* In network order */
  889. };   
  890.  
  891. union ypbind_resp switch (ypbind_resptype ypbind_status) {
  892. case YPBIND_FAIL_VAL:
  893.         unsigned ypbind_error;
  894. case YPBIND_SUCC_VAL:
  895.         ypbind_binding ypbind_bindinfo;
  896. };     
  897.  
  898. /* Detailed failure reason codes for response field ypbind_error*/
  899.  
  900. const YPBIND_ERR_ERR    = 1;    /* Internal error */
  901. const YPBIND_ERR_NOSERV = 2;    /* No bound server for passed domain */
  902. const YPBIND_ERR_RESC   = 3;    /* System resource allocation failure */
  903.  
  904.  
  905. /*
  906.  * Request data structure for ypbind "Set domain" procedure.
  907.  */
  908. struct ypbind_setdom {
  909.     domainname ypsetdom_domain;
  910.     ypbind_binding ypsetdom_binding;
  911.     unsigned ypsetdom_vers;
  912. };
  913.  
  914.  
  915. /*
  916.  * YP access protocol
  917.  */
  918. program YPPROG {
  919.     version YPVERS {
  920.         void 
  921.         YPPROC_NULL(void) = 0;
  922.  
  923.         bool 
  924.         YPPROC_DOMAIN(domainname) = 1;    
  925.  
  926.         bool
  927.         YPPROC_DOMAIN_NONACK(domainname) = 2;
  928.  
  929.         ypresp_val
  930.         YPPROC_MATCH(ypreq_key) = 3;
  931.  
  932.         ypresp_key_val 
  933.         YPPROC_FIRST(ypreq_key) = 4;
  934.  
  935.         ypresp_key_val 
  936.         YPPROC_NEXT(ypreq_key) = 5;
  937.  
  938.         ypresp_xfr
  939.         YPPROC_XFR(ypreq_xfr) = 6;
  940.  
  941.         void
  942.         YPPROC_CLEAR(void) = 7;
  943.  
  944.         ypresp_all
  945.         YPPROC_ALL(ypreq_nokey) = 8;
  946.  
  947.         ypresp_master
  948.         YPPROC_MASTER(ypreq_nokey) = 9;
  949.  
  950.         ypresp_order
  951.         YPPROC_ORDER(ypreq_nokey) = 10;
  952.  
  953.         ypresp_maplist 
  954.         YPPROC_MAPLIST(domainname) = 11;
  955.     } = 2;
  956. } = 100004;
  957.  
  958.  
  959. /*
  960.  * YPPUSHPROC_XFRRESP is the callback routine for result of YPPROC_XFR
  961.  */
  962. program YPPUSH_XFRRESPPROG {
  963.     version YPPUSH_XFRRESPVERS {
  964.         void
  965.         YPPUSHPROC_NULL(void) = 0;
  966.  
  967.         yppushresp_xfr    
  968.         YPPUSHPROC_XFRRESP(void) = 1;
  969.     } = 1;
  970. } = 0x40000000;    /* transient: could be anything up to 0x5fffffff */
  971.  
  972.  
  973. /*
  974.  * YP binding protocol
  975.  */
  976. program YPBINDPROG {
  977.     version YPBINDVERS {
  978.         void
  979.         YPBINDPROC_NULL(void) = 0;
  980.     
  981.         ypbind_resp
  982.         YPBINDPROC_DOMAIN(domainname) = 1;
  983.  
  984.         void
  985.         YPBINDPROC_SETDOM(ypbind_setdom) = 2;
  986.     } = 2;
  987. } = 100007;
  988.  
  989.  
  990. Funky_Stuff
  991. len=`wc -c < yp.x`
  992. if [ $len !=     6130 ] ; then
  993.   echo error: yp.x was $len bytes long, should have been     6130
  994. fi
  995. echo x - yppasswd.x
  996. cat > yppasswd.x <<'Funky_Stuff'
  997. /* @(#)yppasswd.x    1.2 87/11/12 3.9 RPCSRC */
  998. /* @(#)yppasswd.x 1.1 87/04/13 Copyr 1987 Sun Micro */
  999.  
  1000. /*
  1001.  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
  1002.  * unrestricted use provided that this legend is included on all tape
  1003.  * media and as a part of the software program in whole or part.  Users
  1004.  * may copy or modify Sun RPC without charge, but are not authorized
  1005.  * to license or distribute it to anyone else except as part of a product or
  1006.  * program developed by the user.
  1007.  * 
  1008.  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  1009.  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  1010.  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  1011.  * 
  1012.  * Sun RPC is provided with no support and without any obligation on the
  1013.  * part of Sun Microsystems, Inc. to assist in its use, correction,
  1014.  * modification or enhancement.
  1015.  * 
  1016.  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  1017.  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  1018.  * OR ANY PART THEREOF.
  1019.  * 
  1020.  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  1021.  * or profits or other special, indirect and consequential damages, even if
  1022.  * Sun has been advised of the possibility of such damages.
  1023.  * 
  1024.  * Sun Microsystems, Inc.
  1025.  * 2550 Garcia Avenue
  1026.  * Mountain View, California  94043
  1027.  */
  1028.  
  1029. /*
  1030.  * YP password update protocol
  1031.  * Requires unix authentication
  1032.  */
  1033. program YPPASSWDPROG {
  1034.     version YPPASSWDVERS {
  1035.         /*
  1036.          * Update my passwd entry 
  1037.          */
  1038.         int
  1039.         YPPASSWDPROC_UPDATE(yppasswd) = 1;
  1040.     } = 1;
  1041. } = 100009;
  1042.  
  1043.  
  1044. struct passwd {
  1045.     string pw_name<>;    /* username */
  1046.     string pw_passwd<>;    /* encrypted password */
  1047.     int pw_uid;        /* user id */
  1048.     int pw_gid;        /* group id */
  1049.     string pw_gecos<>;    /* in real life name */
  1050.     string pw_dir<>;    /* home directory */
  1051.     string pw_shell<>;    /* default shell */
  1052. };
  1053.  
  1054. struct yppasswd {
  1055.     string oldpass<>;    /* unencrypted old password */
  1056.     passwd newpw;        /* new passwd entry */
  1057. };
  1058.  
  1059.  
  1060. Funky_Stuff
  1061. len=`wc -c < yppasswd.x`
  1062. if [ $len !=     1985 ] ; then
  1063.   echo error: yppasswd.x was $len bytes long, should have been     1985
  1064. fi
  1065. cd ..
  1066. echo done with directory rpcsvc
  1067. exit
  1068.